<template>
  <div class="home">
    <div class="banner"></div>
    <div class="content">
      <div class="middle">
        <div class="video">
          <video src="https://miaocode-ai.oss-ap-southeast-1.aliyuncs.com/gt/storage/2025-01-27/id_4a32f4b412c94a2a98172f135f8cc96f_file_default_video_1.mp4" class="video-player" poster="https://miaocode-ai.oss-ap-southeast-1.aliyuncs.com/gt/storage/2025-01-27/id_c8e75bca90b843edb9d1ba5af141c038_file_default_cover_1.png" autoplay controls></video>
        </div>
      </div>
      <div class="banner2"></div>
      <div class="slogan">
        <div class="slogan-con">
          <div class="title">          
            <p>我们素不相识，本是沉默的孤岛，因为AI，我们相聚，因为热爱，我们熠熠发光。</p>
            <p class="name">—— AI春晚节目组 电子酒</p>
            <p class="desc">AI春晚发起人、总导演</p>
          </div>
        </div>
      </div>
      <div class="logo-list">
        <div v-for="(item,index) in logoList" :key="index">
          <img :src="item"/>
        </div>
      </div>
      <div class="footer">
        <div class="footer-con">
          <div class="login-row">
            <img src="@/assets/image/home/home-logo-white.png" class="bottom-logo"/>
            <div v-if="!loginStore.userinfo.nickname">
              <span>欢迎回来，AI春晚创作者</span>
              <button class="login_btn2" @click="login()">登录</button>
            </div>
          </div>
          <div class="footer-nav">
            <div class="footer-menu">
              <div @click="changeMenu(index, item.path)" v-for="(item, index) in [ {title:'首页',path:'/'}, {title:'节目单',path:'/program-list'}, {title:'热门作品',path:'/video-library'}, {title:'创作者地图',path:'/china-map'}]" :key="index" class="menu-item" :class="activeIdx==index?'active' :''">
              {{ item.title }}
            </div>
            </div>
            <div class="qrcode-group">
              <div class="qrcode">
                <img src="@/assets/image/home/official-account.png"/>
                <span>AI春晚方公众号</span>
              </div>
              <div class="qrcode">
                <img src="@/assets/image/home/contact.png"/>
                <span>商务合作</span>
              </div>              
            </div>
          </div>
          <div class="copyright">Copyright @ 2025 AI春晚  <el-link href="https://beian.miit.gov.cn/" target="_blank">沪ICP备2025111007号-1</el-link></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { onMounted, ref } from "vue";
import { useRouter } from 'vue-router';

import { banner } from "../api/pcApi";
import emitter from '../utils/eventBus';
import { getAssetURL } from '../utils/index'

import { useLoginStore } from '../api/store'; 
const loginStore = useLoginStore();

const activeIdx = ref(0)
const router = useRouter()
const bannerList = ref([
  {
    url: 'https://miaocode-ai.oss-ap-southeast-1.aliyuncs.com/gt/storage/2025-01-21/id_86ea7f85e1b04fd1876854c1ce09f3a8_file_2025-AI.mp4',
    title: '2025 AI春晚',
    cover: '@/assets/image/home/2025.jpg',
    id: 1,
  },
  {
    url: 'https://miaocode-ai.oss-ap-southeast-1.aliyuncs.com/test/2025-01-13/6784d596e4b01764fb0c3de3.mp4',
    title: '2025 AI春晚',
    cover: '@/assets/image/home/2025.jpg',
    id: 2,  
  },
  {
    url: 'https://miaocode-ai.oss-ap-southeast-1.aliyuncs.com/gt/storage/2025-01-21/id_86ea7f85e1b04fd1876854c1ce09f3a8_file_2025-AI.mp4',
    title: '2025 AI春晚',
    cover: '@/assets/image/home/2025.jpg',
    id: 3,
  },
  {
    url: 'https://miaocode-ai.oss-ap-southeast-1.aliyuncs.com/gt/storage/2025-01-21/id_86ea7f85e1b04fd1876854c1ce09f3a8_file_2025-AI.mp4',
    title: '2025 AI春晚',
    cover: '@/assets/image/home/2025.jpg',
    id: 4,  
  },
  {
    url: 'https://miaocode-ai.oss-ap-southeast-1.aliyuncs.com/gt/storage/2025-01-21/id_86ea7f85e1b04fd1876854c1ce09f3a8_file_2025-AI.mp4',
    title: '2025 AI春晚',
    cover: '@/assets/image/home/2025.jpg',
    id: 5
  }
])

const logoList = ref([
  getAssetURL('link-1.png'),
  getAssetURL('link-2.png'),
  getAssetURL('link-3.png'),
  getAssetURL('link-4.png'),
  getAssetURL('link-5.png'),
  getAssetURL('link-6.png'),
  getAssetURL('link-7.png'),
  getAssetURL('link-8.png'),
  getAssetURL('link-9.png'),
  getAssetURL('link-10.png'),
  getAssetURL('link-11.png'),
  getAssetURL('link-12.png'),
])

const getBanner = () => {
  return banner().then(res => {
    bannerList.value = res.map(item => {
      return {
        url: item.url,
        title: item.title,
        cover: item.cover,
        id: item.id
      }
    })
  }).catch(err => {
    console.log(err)
  })
}

const login = () => {
  emitter.emit('open-auth-modal')
}

const changeMenu = (index, path) => {
  activeIdx.value = index
  router.push(path)
}

onMounted(() => {
  // getBanner()
})

</script>

<style lang="less" scoped>
.home {
  overflow-x: hidden;
  .banner {
    text-align: center;
    vertical-align: middle;
    width: 100%;
    height: 822px;
    font-size: 48px;
    // margin-top: 36px;
    background: url('../assets/image/home/banner1.png') #961616 no-repeat;
    background-size: 100% 100%;
  }
  .content {
    .middle {  
      width: 1160px;
      margin-left: auto;
      margin-right: auto;
      .video {
				margin-top: 50px;
        margin-bottom: 50px;
        .video-player {
          width: 100%;
          height: 651px;
        }
      }
      .map {
        width: 100%;  
        height: 700px;
        background-color: #961616;
        color: #fff;
      }
    }
    .banner2 {
      height: 846px;
      margin: 50px 0;
      background: url('../assets/image/home/banner3.png') no-repeat;
      background-size: 1468px 100%;
      background-position: center;
    }
    .slogan {
      width: 1160px;
      height: 281px;
			margin-bottom: 64px;
      margin-left: auto;
      margin-right: auto;      
      background: url('../assets/image/home/slogan-bg.jpg') no-repeat;
      background-size: cover;
      color: #fff;
      .slogan-con {
        width: fit-content;
        margin-left: auto;
        margin-right: 168px;
        position: relative;
        overflow: hidden;
        padding: 56px 85px 0 85px;
        &:before,
        &:after {
          content: "";
          position: absolute;          
          width: 62px;
          height: 51px;
        }        
        &:before {
          background: url('../assets/image/home/double-quotes1.png') no-repeat;
          background-size: cover;
          left: 0;
          top: 42px;
          opacity: 0.5;
        }
        &:after {
          background: url('../assets/image/home/double-quotes2.png') no-repeat;
          background-size: cover;
          opacity: 0.5;
          right: 23px;
          bottom: 100px;
        }  
      }
      .title {
        font-size: 28px;
        font-weight: 700;
        width: 422px;
        margin-bottom: 30px;
        .name {
          margin-top: 30px;
          font-size: 18px;
        }
        .desc {
          font-size: 16px;
          color: #EDEDED;
          margin-top: 3px;
          font-weight: 400;
        }
      }
    }
    .logo-list {
      height: 380px;
      background: #F5F8FE;
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      img {
        width: 300px;
        height: 70px;
      }
    }
    .footer {
      color: #fff;
      background: #101010;
      padding-bottom: 100px;
      .footer-con {
        width: 1160px;
        padding-top: 93px;
        margin-left: auto;
        margin-right: auto;
        .login-row {
          display: flex;
          justify-content: space-between;
          font-size: 16px;
          padding-bottom: 35px;
          border-bottom: 1px solid #757B8A;
          margin-bottom: 40px;
          img {
            width: 204px;
            height: 61px;
          }
          .login_btn2 {
            background: #A30000;
            color:#fff;
            padding-top: 12px;
            padding-bottom: 12px;
            width: 188px;
            border: 0;
            border-radius: 8px;
            margin-left: 16px;
            cursor: pointer;
          }        
        }
        .footer-nav {
          display: flex;
          justify-content: space-between;
          .footer-menu {
            display: flex;
            flex-direction: column;
            .menu-item {
              cursor: pointer;
              color: #EDEDED;
            }
            .menu-item + .menu-item {
              margin-top: 16px;
            }
            .active {
              color: #fff;
              font-size: 18px;
              font-weight: 700;
            }         
          }
          .qrcode-group {
            display: flex;
            justify-content: space-between;
            .qrcode {
              width: fit-content;
              img {
                width: 160px;
                height: 160px;
              }
              span {
                margin-top: 10px;
                display: block;
                text-align: center;
              }
            }
            .qrcode + .qrcode{
              margin-left: 54px;
            }
          }
        }
        .copyright{
          color: #D6D6D6;
          margin-top: 58px;
          a {
            margin-left: 16px;
            font-size: 16px;
            vertical-align: bottom;
          }
        }
      }
    }
  }
}
</style>